package com.bs.core.controller;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;

import com.bs.utils.json.AjaxJson;
import com.bs.utils.log.LogUtil;

/**********************************************************
 *
 * 文件名称：BaseController.java 
 * 摘    要：
 *
 * 初始版本：1.0.0.0
 * 原 作 者：叶平平
 * 完成日期：2015-12-28 下午2:19:49
 * 
 ************************************************************/
public abstract class BaseController {
	private static Logger logger = LogUtil.get();
	
	protected String getRealIp(HttpServletRequest request){
		String realIP = request.getHeader("x-forwarded-for");
		
		if(realIP == null || realIP.length() == 0 || "unknown".equalsIgnoreCase(realIP)) {
			realIP = request.getHeader("myclientip");
		}else if(realIP == null || realIP.length() == 0 || "unknown".equalsIgnoreCase(realIP)) {
			realIP = request.getHeader("Proxy-Client-IP");
		}else if(realIP == null || realIP.length() == 0 || "unknown".equalsIgnoreCase(realIP)) {
			realIP = request.getHeader("WL-Proxy-Client-IP");
		}else if(realIP == null || realIP.length() == 0 || "unknown".equalsIgnoreCase(realIP)) {
			realIP = request.getRemoteAddr();
		}
		return realIP ;
	}
	
	public AjaxJson getAjaxJson(){	
		return new AjaxJson();
	}
}
